﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SQLiteDictionary;
using System.Collections.ObjectModel;

namespace TestApplication
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private SqliteDictionary<string, string> StringData;
        private SqliteDictionary<string, double> DoubleData;
        private SqliteDictionary<string, bool> BoolData;
        ObservableCollection<SqliteKeyValuePar<string, string>> _collection;

        public MainWindow()
        {
            InitializeComponent();

            try
            {
                StringData = new SqliteDictionary<string, string>();
                DoubleData = new SqliteDictionary<string, double>();
                BoolData = new SqliteDictionary<string, bool>();

                INIVars();
                INIEvents();
            }
            catch (Exception ex)
            {
                string error = ex.ToString();
            }
        }

        public void INIVars()
        {
            StringData.Create("TextBox", "Write some text");
            DoubleData.Create("Slider", 50.0);
            BoolData.Create("CheckBox", false);

            _myTextBox.Text = StringData["TextBox"];
            _slider.Value = DoubleData["Slider"];
            _myCheckBox.IsChecked = BoolData["CheckBox"];

            _txt_key.Text = "";
            _txt_Value.Text = "";

            LoadVars();
        }
        public void INIEvents()
        {

        }

        public void LoadVars()
        {
            _listView.ItemsSource = null;
            _collection = new ObservableCollection<SqliteKeyValuePar<string, string>>();
            foreach (var v in StringData)
                _collection.Add(v);
            _listView.ItemsSource = _collection;
        }
    }
}
